<template>
    <div class="search">
        <van-search v-model="value" placeholder="请输入搜索关键词" @input="toolTipTitle" />
        <div  v-for="item in arr1" :key="item.id" v-html="item" ></div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            h: '',
            value:'',
            arr:[
                '王政泽','伍奇','曹晓旭','李静','蒋雪娇','黎婷','任山崎','王晓','牛肉面(双蛋)'
            ],
            titleIdCodeText:'',
            arr1:[]
        }
    },
    created(){
        this.h = window.innerHeight + 'px'
    },
    methods: {
        toolTipTitle() {
            this.arr1=[]
            this.arr.forEach(item => {
                if(item.includes(this.value)&&this.value != ''){
                    this.titleIdCodeText = item
                    this.titleIdCodeText = this.titleIdCodeText.split(this.value).join(`<font color=red>${this.value}</font>`)
                    this.arr1.push(this.titleIdCodeText)
                }
            });
    },
   
    
  },

}
</script>
<style scoped>

</style>